<?php
/**
 * Created by PhpStorm.
 * User: chenzhitao
 * Date: 2018/6/21
 * Time: 下午2:03
 */

namespace app\index\service;


use app\index\model\ThirdUrl;
use app\index\model\UrlTag;

class UrlService
{
    const CATEGORY_KEY = "url_list_key";
    const EXPIRE_IN = 60*2;
    /**
     * 获取首页友情链接
     */
    public static function getIndexThirdUrlList(){
        $cache_list = cache(self::CATEGORY_KEY);
        if($cache_list){
            return $cache_list;
        }
        $list = UrlTag::getAll();

        if($list){
            foreach ($list as &$item){
                $item['url_list'] = ThirdUrl::getUrlListByTagId($item['id']);
            }
        }
        cache(self::CATEGORY_KEY,$list,self::EXPIRE_IN);
        return $list;
    }
}